/**
 * 这节和上一节是一样的  只是实现的思路是使用装饰器工厂
 */

{
	const SleepDecoratorFactor = (time: number): MethodDecorator => {
		return (
			target: Object,
			propertyKey: string | symbol,
			descriptor: PropertyDescriptor
		) => {
			let method = descriptor.value
			descriptor.value = () => {
				setTimeout(() => {
					method()
				}, time)
			}
		}
	}

	class User {
		@SleepDecoratorFactor(5000)
		public code(): void {
			console.log('code!!!!')
		}
	}

	new User().code()
}
